package com.zhanbo.zhanbowymusic;

import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.View;

import com.mwx.baselib.base.BaseActivity;
import com.mwx.baselib.bean.HomeBannerBean;
import com.mwx.baselib.bean.LoginBean;
import com.mwx.baselib.net.BaseResponses;
import com.mwx.baselib.net.DefaultObserver;
import com.mwx.baselib.net.NetworkManager;
import com.mwx.baselib.utils.MLog;
import com.mwx.baselib.utils.SPUtils;
import com.zhanbo.zhanbowymusic.databinding.ActivityMainBinding;
import com.zhanbo.zhanbowymusic.dialog.BuyVipDialog;
import com.zhanbo.zhanbowymusic.main.HomeFragment;
import com.zhanbo.zhanbowymusic.dialog.PlayListDialog;
import com.zhanbo.zhanbowymusic.music.MusicController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import me.yokeyword.fragmentation.ISupportFragment;

public class MainActivity extends BaseActivity<ActivityMainBinding> implements View.OnClickListener {

    private ISupportFragment[] mFragments;
    MainFragment mainFragment = new MainFragment();
    PlayListDialog playListDialog;
    @Override
    protected void init(Bundle savedInstanceState) {
        loadRootFragment(R.id.fl_main,mainFragment);
        initView();
        initListener();
            Map<String, String> map = new HashMap<>();
            map.put("mobile", "13812345678");
            map.put("password", "123456");
        NetworkManager.getInstance().getApiService().login(map)
                    .subscribeOn(Schedulers.io())
                    .compose(this.bindToLifecycle())
                    .observeOn(AndroidSchedulers.mainThread()).subscribe(new DefaultObserver<BaseResponses<LoginBean>>(_activity) {
                        @Override
                        public void onSuccess(BaseResponses<LoginBean> listBaseResponses) {
                            MLog.e(listBaseResponses.getData().getToken());
                            SPUtils.put(SPUtils.TOKEN,listBaseResponses.getData().getToken()+"");
                        }
                    });


    }

    private void initView() {
        playListDialog = new PlayListDialog(_activity,R.id.fl_main);
    }


    @Override
    protected Object getLayout() {
        return R.layout.activity_main;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {

    }
    public void showPlayListDialog(){
        if (playListDialog.isShowing()) {
            playListDialog.dismiss();
        } else {
            playListDialog.show();
        }
    }
    public void showBuyVipDialog(){
        BuyVipDialog buyVipDialog  =new BuyVipDialog(_activity,R.id.ll_home);
        buyVipDialog.show();
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){

        }
    }
    public void showDockBar(){
//        binding.rlDockBar.setVisibility(View.VISIBLE);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        MusicController.getInstance().destroyEvent();
    }
}